package it.unisa.draggablenodeTool.common;

import java.util.Hashtable;

public class ColoredUsers {
	public static final int NO_COLOR = -1;
	
	Hashtable userList;

	public ColoredUsers () {
		userList = new Hashtable();
	}
	
	public int getUserColor(String user) {
		
		synchronized (userList) { // one at the time, please!
			Integer c = ((Integer) userList.get(user));
			// if the user is not in the list, add it with the new colorIndex and return it
			if (c == null) { 
				// add a new user with the new color index and return it
				userList.put(user, new Integer(userList.size()+1));				
			}	
		} 
		return ((Integer) userList.get(user)).intValue(); 
	}

}
